/**
 * 
 */
package com.wqr.it.ecwdr.vo;

import java.util.List;

/**
 * @author adinos
 *
 */
public class Product extends ProductSalesInfoVO {
	private static final long serialVersionUID = -4988082501208260681L;
	private SallerVO sallerVO;
	private ProductFinancialVO financialVO;
	private ProductCategoryVO categoryVO;
	private ProductImgUrlVO imgUlrVO;
	private DiscoveryVO discoveryVO;
	private List<TagVO> tagList;
	public Product() {
		super();
	}
	
	public Product(ProductSalesInfoVO productSalesInfoVO) {
		this();
		super.setProductItemInfo(productSalesInfoVO);
		this.setCountry(productSalesInfoVO.getCountry());
		this.setCountryId(productSalesInfoVO.getCountryId());
		this.setFba(productSalesInfoVO.getFba());
		this.setPrime(productSalesInfoVO.getPrime());
		this.setPrice(productSalesInfoVO.getPrice());
		this.setSallerVO(productSalesInfoVO.getSallerVO());
		this.setSallerId(productSalesInfoVO.getSallerId());
		this.setListPrice(productSalesInfoVO.getListPrice());
		this.setShipping(productSalesInfoVO.getShipping());
		this.setFreeShipping(productSalesInfoVO.getFreeShipping());
		this.setDeliveryVO(productSalesInfoVO.getDeliveryVO());
		this.setStockId(productSalesInfoVO.getStockId());
		this.setProductSallerId(productSalesInfoVO.getProductSallerId());
		this.setSku(productSalesInfoVO.getSku());
		this.setItemId(productSalesInfoVO.getItemId());
		this.setVersion(productSalesInfoVO.getVersion());
	}
	/**
	 * @return the sallerVO
	 */
	public SallerVO getSallerVO() {
		return sallerVO;
	}
	/**
	 * @param sallerVO the sallerVO to set
	 */
	public void setSallerVO(SallerVO sallerVO) {
		this.sallerVO = sallerVO;
	}
	
	@Override
	public long getSallerId() {
		if (this.sallerVO != null) {
			return this.sallerVO.getId();
		} else {
			return super.getSallerId();
		}
	}
	/**
	 * @return the financialVO
	 */
	public ProductFinancialVO getFinancialVO() {
		return financialVO;
	}
	/**
	 * @param financialVO the financialVO to set
	 */
	public void setFinancialVO(ProductFinancialVO financialVO) {
		this.financialVO = financialVO;
	}
	/**
	 * @return the categoryVO
	 */
	public ProductCategoryVO getCategoryVO() {
		return categoryVO;
	}
	/**
	 * @param categoryVO the categoryVO to set
	 */
	public void setCategoryVO(ProductCategoryVO categoryVO) {
		this.categoryVO = categoryVO;
	}
	/**
	 * @return the imgUlrVO
	 */
	public ProductImgUrlVO getImgUlrVO() {
		return imgUlrVO;
	}
	/**
	 * @param imgUlrVO the imgUlrVO to set
	 */
	public void setImgUlrVO(ProductImgUrlVO imgUlrVO) {
		this.imgUlrVO = imgUlrVO;
	}
	/**
	 * @return the discoveryVO
	 */
	public DiscoveryVO getDiscoveryVO() {
		return discoveryVO;
	}
	/**
	 * @param discoveryVO the discoveryVO to set
	 */
	public void setDiscoveryVO(DiscoveryVO discoveryVO) {
		this.discoveryVO = discoveryVO;
	}
	/**
	 * @return the tagList
	 */
	public List<TagVO> getTagList() {
		return tagList;
	}
	/**
	 * @param tagList the tagList to set
	 */
	public void setTagList(List<TagVO> tagList) {
		this.tagList = tagList;
	}
	
	public ProductSimpleVO getSimple() {
		ProductSimpleVO simple = new ProductSimpleVO();
		simple = new ProductSimpleVO();
		simple.setId(this.getId());
		simple.setNumber(this.getNumber());
		simple.setCountry(this.getCountry());
		simple.setName(this.getName());
		simple.setDescription(this.getDescription());
		simple.setRemark(this.getRemark());
		
		// 财经信息
		ProductFinancialVO fin = this.getFinancialVO();
		if (fin != null) {
			simple.setBeforeDiscount(fin.getBeforeDiscount());
			simple.setPrice(fin.getPrice());
			if (fin.getBrandId() != 0) {
				simple.setIsBrand("Y");
			}
			if (fin.getFreeShipping() != 0) {
				simple.setIsFreeShipping("Y");
			}
		}
		
		// 目录信息
		if (this.getCategoryVO() != null) {
			simple.setCategory(this.getCategoryVO().getName());
		}
		
		// 标签
		List<TagVO> tagList = this.getTagList();
		if (tagList != null && tagList.size() > 0) {
			StringBuffer sb = new StringBuffer();
			for (TagVO tagVO : tagList) {
				sb.append(tagVO.getName() + ",");
			}
			simple.setTag(sb.toString());
		}
		return simple;
	}
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "Product [getId()=" + getId() + ", " + (getNumber() != null ? "getNumber()=" + getNumber() + ", " : "")
				+ (getCountry() != null ? "getCountry()=" + getCountry() + ", " : "")
				+ (getName() != null ? "getName()=" + getName() + ", " : "")
				+ (getDescription() != null ? "getDescription()=" + getDescription() + ", " : "")
				+ (getRemark() != null ? "getRemark()=" + getRemark() + ", " : "") + "getSallerId()=" + getSallerId()
				+ ", getCategoryId()=" + getCategoryId() + ", getModId()=" + getModId() + ", "
				+ (sallerVO != null ? "sallerVO=" + sallerVO + ", " : "")
				+ (financialVO != null ? "financialVO=" + financialVO + ", " : "")
				+ (categoryVO != null ? "categoryVO=" + categoryVO + ", " : "")
				+ (imgUlrVO != null ? "imgUlrVO=" + imgUlrVO + ", " : "")
				+ (discoveryVO != null ? "discoveryVO=" + discoveryVO + ", " : "")
				+ (tagList != null ? "tagList=" + tagList : "") + "]";
	}
}
